from ronglian_sms_sdk import SmsSDK
import json
from django.conf import settings
# accId = "2c94811c9035ff9f01923173f41d6611"
# accToken = "28e1f9c9b6a940d79e02b2c34b35810b"
# appId = "2c94811c9035ff9f019232186d1566a4"

def send_message(tid, mobile, datas):
    ronglianyun = settings.RONGLIANYUN
    sdk = SmsSDK(ronglianyun.get('accId'), ronglianyun.get('accToken'), ronglianyun.get('appId'))
    # tid = "1"
    # mobile = '18201275696'
    # datas = ('9823', '2')
    resp = sdk.sendMessage(tid, mobile, datas)
    # 字符串转字段，将容联云返回的json格式的字符串转换称python中的字典格式数据
    response = json.loads(resp)
    print(resp)
    # 判断端发送是否成功，返回True False
    return response.get("statusCode") == "000000"